package com.bsdsma.visonManagementSystemapp.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 视力报告表
 */
@Data
@Entity
@KeySequence(dbType = DbType.MYSQL)
@TableName("baogao")
@Table(name = "baogao", indexes = {
    @Index(name = "idx_xuehao_year", columnList = "xuehao,year", unique = true),
    @Index(name = "idx_xuehao", columnList = "xuehao")
})
public class Baogao implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 主键ID 自增
     */
    @Id
    @Column(length = 20)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;

    @Column(name = "xuehao", columnDefinition = "bigint not null")
    private Long xuehao;

    @Column(name = "left_eye", columnDefinition = "decimal(4,2) not null")
    private Double leftEye;

    @Column(name = "right_eye", columnDefinition = "decimal(4,2) not null")
    private Double rightEye;

    @Column(name = "conclusion", columnDefinition = "varchar(500) not null DEFAULT ''")
    private String conclusion;

    @Column(name = "recommend", columnDefinition = "varchar(500) not null DEFAULT ''")
    private String recommend;

    @Column(name = "year", columnDefinition = "int not null")
    private Integer year;

    @Column(name = "alert", columnDefinition = "varchar(20) not null DEFAULT ''")
    private String alert;

    /**
     * 创建时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "ct", columnDefinition = "datetime not null")
    private Date ct;
    /**
     * 更新时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "ut", columnDefinition = "datetime not null")
    private Date ut;

    /**
     * 学号 - 关联学生表
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "xuehao", referencedColumnName = "xuehao", insertable = false, updatable = false)
    private Student student;
}
